import axios from '@/lib/script/http'

const getBaseUrl = () => {
  return ''
}

// 添加团队
export const postTeamInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team/`,
      method: 'POST',
      data: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 查询团队(单个)
export const getTeamInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team/${args.id}`,
      method: 'GET',
      params: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}
// 查询团队列表
export const getTeamList = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team/`,
      method: 'GET',
      params: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 修改团队信息
export const updateTeamInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team/${args.id}`,
      method: 'PUT',
      data: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 删除团队
export const delTeamInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team/${args.id}`,
      method: 'DELETE',
      params: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 邀请(用户)加入团队
export const postUserInTeamCode = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team_relation/invitation`,
      method: 'POST',
      data: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}
// 邀请(用户)加入团队
export const postUserInTeam = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team_relation/`,
      method: 'POST',
      data: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 获取团队用户列表
export const getTeamUser = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team_relation/users/${args.tid}`,
      method: 'GET',
      params: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 把用户从团队中移除
export const delUserOfTeam = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/team_relation/`,
      method: 'DELETE',
      params: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}